/***************************************************************************************************
 * Copyright (c) 2015-2020 Intelligent Network System Ltd. All Rights Reserved. 
 * 
 * This software is the confidential and proprietary information of Founder. You shall not disclose
 * such Confidential Information and shall use it only in accordance with the terms of the 
 * agreements you entered into with Founder. 
***************************************************************************************************/

#ifndef __SX127X_SPI_H__
#define __SX127X_SPI_H__
/***************************************************************************************************
 * INCLUDES
 */
#include "stdint.h"
#include "stdbool.h"

#ifdef __cplusplus
extern "C"{
#endif



/***************************************************************************************************
 * GLOBAL FUNCTIONS DECLEAR
 */
/*!
 * @fn      sx127x_SpiInit()
 */
void sx127x_SpiInit(void);

/*!
 * @fn      sx127x_SpiDeInit()
 */
void sx127x_SpiDeInit(void);


/*!
 * \brief Writes the radio register at the specified address
 *
 * \param [IN]: addr Register address
 * \param [IN]: data New register value
 */
void SX127xWrite( uint8_t addr, uint8_t data );

/*!
 * \brief Reads the radio register at the specified address
 *
 * \param [IN]: addr Register address
 * \param [OUT]: data Register value
 */
void SX127xRead( uint8_t addr, uint8_t *data );

/*!
 * \brief Writes multiple radio registers starting at address
 *
 * \param [IN] addr   First Radio register address
 * \param [IN] buffer Buffer containing the new register's values
 * \param [IN] size   Number of registers to be written
 */
void SX127xWriteBuffer( uint8_t addr, uint8_t *buffer, uint8_t size );

/*!
 * \brief Reads multiple radio registers starting at address
 *
 * \param [IN] addr First Radio register address
 * \param [OUT] buffer Buffer where to copy the registers data
 * \param [IN] size Number of registers to be read
 */
void SX127xReadBuffer( uint8_t addr, uint8_t *buffer, uint8_t size );

/*!
 * \brief Writes the buffer contents to the radio FIFO
 *
 * \param [IN] buffer Buffer containing data to be put on the FIFO.
 * \param [IN] size Number of bytes to be written to the FIFO
 */
void SX127xWriteFifo( uint8_t *buffer, uint8_t size );

/*!
 * \brief Reads the contents of the radio FIFO
 *
 * \param [OUT] buffer Buffer where to copy the FIFO read data.
 * \param [IN] size Number of bytes to be read from the FIFO
 */
void SX127xReadFifo( uint8_t *buffer, uint8_t size );


/*!
 * sx127x_SpiDelay__()
 */
void sx127x_SpiDelay__( uint32_t a_u16DelayCnt );



#ifdef __cplusplus
}
#endif


#endif /* __sx127x_SPI_H__ */
 
 
 
